home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 February
/
EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso
/
enigma
/
earcd
/
utility
/
utilfile
/
lha2lzx.lha
/
LHA2LZX.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-01-07
|
6KB
|
180 lines
/* This script converts LHA archives to LZX archives
* Author: Martin Hilpert (hima0011@fh-karlsruhe.de)
* $VER: LHA2LZX 1.2 (07.01.97) © 1996 by Martin Hilpert (hima0011@fh-karlsruhe.de)
*/
ADDRESS COMMAND /* for executing DOS commands */
IF ARG() ~= 1 THEN DO
SAY "usage: rx LHA2LZX [options] <LHA archive with full path> <destination path>"
SAY "options are: -t enable testing of archives"
SAY " -f enable filenote"
SAY " -n disable deletion of dearchived files"
SAY " -s Amiga talks ..."
SAY " +v<PathOfVirusZ> enable virus checking"
SAY " +z<TempPath> path for the temporary directory"
EXIT 5
END
/* split argument string to different parts */
PARSE ARG Arguments
iDevice = LASTPOS(":",Arguments)
iDevice = LASTPOS(":",Arguments,iDevice-1)
iSpace1 = LASTPOS(" ",Arguments,iDevice)
Options = SUBSTR(Arguments,1,iSpace1)
iSpace2 = POS(" ",Arguments,iDevice)
iSourcePath = LASTPOS("/",Arguments,iSpace2)
SourcePath = SUBSTR(Arguments,iSpace1+1,iSourcePath-iSpace1)
LhaArchive = SUBSTR(Arguments,iSourcePath+1,iSpace2-1-iSourcePath)
Basename = SUBSTR(LhaArchive,1,LASTPOS(".",LhaArchive)-1)
iSpace1 = LASTPOS(" ",Arguments)
iDevice = LASTPOS(":",Arguments)
iSpace2 = LASTPOS(" ",Arguments,iDevice)
DestinationPath = SUBSTR(Arguments,iSpace2+1,LENGTH(Arguments)-iSpace2)
IF POS("-t",Options) ~= 0 THEN
o_test = 1
else
o_test = 0
IF POS("-s",Options) ~= 0 THEN
o_speech = 1
else
o_speech = 0
IF POS("-f",Options) ~= 0 THEN
o_filenote = 1
else
o_filenote = 0
IF POS("-n",Options) ~= 0 THEN
o_nodelete = 1
else
o_nodelete = 0
/* temporary path for dearchived files */
TempPath = "RAM:" /* default path */
Index = POS("+z",Options)
IF Index ~= 0 THEN DO
iSpace = POS(" ",Options,Index) /* end of +zDevice:Path */
IF iSpace == 0 THEN /* last option ? */
iSpace = LENGTH(Options) + 1
TempPath = SUBSTR(Options,Index+2,iSpace-Index-2)
TempPath = SPACE(TempPath,0)
IF LASTPOS("/",TempPath) ~= LENGTH(TempPath) THEN /* last character a slash? */
TempPath = TempPath || "/" /* slash is mandatory */
END
TempPath = TempPath || "LHA2LZX/"
o_virustest = 0
Index = POS("+v",Options)
IF Index ~= 0 THEN DO
iSpace = POS(" ",Options,Index) /* end of +vDevice:Path */
IF iSpace == 0 THEN /* last option ? */
iSpace = LENGTH(Options) + 1
ViruszPath = SUBSTR(Options,Index+2,iSpace-Index-2)
ViruszPath = SPACE(ViruszPath,0)
IF EXISTS(ViruszPath'VirusZ') == 1 THEN
o_virustest = 1
else
'echo "*E[31;42mCan''t find VirusZ!*E[0m"'
END
IF POS("-c",Options) ~= 0 THEN DO
'echo " options:"' Options
'echo " source directory:"' SourcePath
'echo " archive:"' LhaArchive
'echo " basename:"' Basename
'echo "destination directory:"' DestinationPath
'echo " temporary directory:"' TempPath
IF o_virustest == 1 THEN
'echo " VirusZ location:"' ViruszPath
END
/**************************************/
IF o_test = 1 THEN DO
'echo "*E[32;41mtesting LHA archive ...*E[0m"'
IF o_speech = 1 THEN
'say "testing Elleigeigh r kive"'
'LHA -b64 -F t' SourcePath || LhaArchive
IF RC ~= 0 THEN DO
'FILENOTE' SourcePath || LhaArchive 'COMMENT "FAILED archive test!"'
'echo "*E[31;42mLHA archive test failed!*E[0m (exiting...)"'
IF o_speech = 1 THEN
'say "Attention! Something went wrong!"'
EXIT 10
END
IF o_filenote = 1 THEN
'FILENOTE' SourcePath || LhaArchive 'COMMENT "archive tested"'
END
/**************************************/
'echo "*E[32;41mdearchiving LHA ...*E[0m"'
'DELETE' TempPath'#? ALL FORCE QUIET' /* clear TempPath */
IF RC ~= 0 & RC ~= 5 THEN DO /* is there some stuff left? */
'echo "*E[31;42mCan''t delete whole temporary directory!*E[0m (exiting...)"'
IF o_speech = 1 THEN
'say "Attention! Something went wrong!"'
EXIT 10
END
IF o_speech = 1 THEN
'say "unpacking Elleigeigh r kive"'
'LHA -b64 -F x' SourcePath || LhaArchive TempPath
IF RC ~= 0 THEN DO
'FILENOTE' SourcePath || LhaArchive 'COMMENT "FAILED dearchiving!"'
'echo "*E[31;42mLHA dearchiving failed!*E[0m (exiting...)"'
IF o_speech = 1 THEN
'say "Attention! Something went wrong!"'
EXIT 10
END
/**************************************/
IF o_virustest = 1 THEN DO
'echo "*E[32;41mchecking files for viruses ...*E[0m"'
IF o_speech = 1 THEN
'say "Checking files for viruses"'
ViruszPath'VirusZ CX_POPUP=NO FILECHECK' TempPath'#? ALL'
IF RC ~= 0 THEN DO
'echo "*E[31;42mVirus checking failed!*E[0m (exiting...)"'
IF o_speech = 1 THEN
'say "Attention! Something went wrong!"'
EXIT 10
END
END
/**************************************/
'echo "*E[32;41marchiving to LZX archive ...*E[0m"'
IF o_speech = 1 THEN
'say "packing files to Elzetex r kive"'
/* save path and cd to temporary path */
OriDir = PRAGMA('D',TempPath)
'LZX -r -e -3 -M8000 -F -Y -bi256 -bo256 -wRAM: a' DestinationPath || Basename '*'
IF RC ~= 0 THEN DO
'echo "*E[31;42mLZX archiving failed!*E[0m (exiting...)"'
IF o_speech = 1 THEN
'say "Attention! Something went wrong!"'
EXIT 10
END
RC = PRAGMA('D',OriDir) /* restore old path */
IF o_nodelete = 0 THEN
'DELETE' TempPath'#?' TempPath 'ALL FORCE QUIET'
/**************************************/
IF o_test = 1 THEN DO
'echo "*E[32;41mtesting LZX archive ...*E[0m"'
IF o_speech = 1 THEN
'say "testing Elzetex r kive"'
'LZX -F t' DestinationPath || Basename
IF o_filenote = 1 THEN
'FILENOTE' DestinationPath || Basename || ".lzx" 'COMMENT "archive tested"'
END
SAY "LHA2LZX finished - goodbye!"
IF o_speech = 1 THEN
'say "Elleigeigh to Elzetex finished - goodbuy!"'
End:
EXIT